package com.logic.modular.act.playerInfo;

import com.comment.pojo.domain.logic.domain.PlayerRank;
import com.comment.util.message.ResponseResult;
import com.logic.comment.util.JwtUtils;
import com.logic.modular.game.player.info.PlayerRankServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Set;

/**
 * 游戏账户(Player)表服务控制层
 *
 * @author cxy
 * @since 2024-07-18 10:05:14
 */
@Api(tags = "段位信息")
@Validated
@RestController
@RequestMapping("/rankAct")
public class RankAction {
    @Resource
    private PlayerRankServiceImpl playerRankService;

    @ApiOperation(value = "胜点排行")
    @PostMapping("/winningPoints")
    public ResponseResult<Set<PlayerRank>> winningPoints(
            @RequestHeader String token
    ) {
        Long playerId = JwtUtils.getPlayerId(token);
        return ResponseResult.success(playerRankService.winningPoints(playerId));
    }

    @ApiOperation(value = "段位排名")
    @PostMapping("/rank")
    public ResponseResult<Set<PlayerRank>> rank(
            @RequestHeader String token
    ) {
        return ResponseResult.success(playerRankService.rank(JwtUtils.getPlayerId(token)));
    }

    @ApiOperation(value = "主公等级排行")
    @PostMapping("/rankRankingOfPrincipalOfficials")
    public ResponseResult<Set<PlayerRank>> playerGrade(
            @RequestHeader String token
    ) {
        return ResponseResult.success(playerRankService.playerGrade(JwtUtils.getPlayerId(token)));
    }
}
